package com.alterzhang.userservice.proxy.cglib;


import org.springframework.cglib.proxy.Enhancer;
import org.springframework.cglib.proxy.MethodInterceptor;
import org.springframework.cglib.proxy.MethodProxy;

;import java.lang.reflect.Method;

public class Huangniu implements MethodInterceptor {


    public Object getInstance(Object obj) {

        Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(obj.getClass());

        enhancer.setCallback(this);
        return enhancer.create();

    }


    @Override
    public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {

        System.out.println("-------开始代理-----------");
        methodProxy.invokeSuper(o,objects);
        return null;
    }
}
